#ifndef QMEMERYMANAGER_H
#define QMEMERYMANAGER_H

#include "sharedlibglobal.h"

#include <QObject>
#include <QList>
#include <QStringList>
#include <QMap>

class QXmlStreamReader;

namespace SHAREDLIB
{

    class SHAREDLIB_EXPORT QMemeryManager : public QObject
    {
        Q_OBJECT
    public:
        explicit QMemeryManager(QObject *parent = 0);
        ~QMemeryManager();

        void        addData(QObject* obj);
        void        removeData(const QString &group,const QString& name);
        void        removeDatas(const QList<QObject*> &datas);
        QObject*    getData(int index);
        QObject*    getData(const QString &group,const QString& name);
        int         dataIndex(QObject* obj);
        int         dataCount();

        void        load(const QString &projectPath);
        void        save(const QString &projectPath);
        void        clear();
        void        refreshData();
        QStringList namesList(const QString &group);
        QStringList groups();
        void        changedName(const QString &newName,QObject* obj);
        void        changedData(const QVariant &data,QObject* obj);
    protected:
        void        readData(QXmlStreamReader* r);

    signals:
        void    refresh();
        void    addDataSignal(QObject* obj);
        void    removeDataSignal(QObject* obj);
        void    dataChanged(QObject* obj);
    protected:
        QList<QObject*>     m_datas;
        QMap<QString,QMap<QString,QObject*> >   m_groupToObject;
    };

}
#endif // QMEMERYMANAGER_H
